extends Node
func _ready():
	pass
func _init():
	config.bfDir["<无敌>"] = "受到伤害时降低至0"
	config.bfDir["<内伤>"] = "技能CD延长2秒"
	config.bfDir["<沉默>"] = "无法释放技能"
	config.bfDir["<坚毅>"] = "物理防御提升5%，每一层增加2%，上限20层，每秒减少层数"
	config.bfDir["<强攻>"] = "物理攻击提升20%，每一层增加2%，上限20层，每秒减少层数"
	config.bfDir["<眩晕>"] = "无法移动、攻击、施放技能，但技能CD会照常冷却"
	config.bfDir["<摔倒>"] = "无法移动、攻击、施放技能，受到伤害时增加20%，持续3秒"
	config.bfDir["<沉睡>"] = "无法行动，沉睡1秒后受到攻击则解除"
	config.bfDir["<饱腹>"] = "吃得太饱了不适合运动，攻速下降80%，伤害下降30%，持续3秒"
	config.bfDir["<硬直>"] = "无法移动、攻击、施放技能，闪避率下降50%"
	config.bfDir["<唯一>"] = "只能存在一个，无法重复叠加"
	config.bfDir["<先发>"] = "开局释放一次"
	config.bfDir["<灼烧>"] = "每秒造成最大体力1%的真实伤害，每层提升0.2%，最高20层，每秒减少层数"
	config.bfDir["<必中>"] = "必定命中"
	config.bfDir["<破甲>"] = "陷入物防脆弱状态，物防减少50%"
	config.bfDir["<混乱>"] = "每秒随机更换仇恨目标,无法被白银盾免疫"
	config.bfDir["朱雀印记"] = "朱雀的技能会对有印记的目标造成额外效果"
	config.bfDir["<溺水>"] = "每秒造成最大体力5%的魔法伤害，每秒减少层数"
	config.bfDir["元素庇护"] = "每秒恢复3%最大生命值，持续6秒"
	config.bfDir["<剧毒>"] = "每秒造成最大体力4%的物理伤害，每秒减少层数"
	config.bfDir["<束缚>"] = "无法普攻"
	config.bfDir["<寄生>"] = "每秒吸取目标3%最大生命值"
	config.bfDir["<麻痹>"] = "释放技能时有50%的概率释放失败"
	config.bfDir["<耀光>"] = "引爆时造成至高之眼50%攻击力的真实特效伤害，最高一层"
	config.bfDir["<警觉>"] = "伤害抗性提升15%，失去所有技能"
	config.bfDir["<唯一>"] = "只能同时存在一个该技能"
	config.bfDir["<禁疗>"] = "无法获得治疗"
	config.bfDir["<沼泽>"] = "攻速降低30%，每秒降低7%当前体力值"
	config.bfDir["<诅咒>"] = "普攻对自身造成[物攻*0.5]伤害，施放技能对自身造成[魔攻]伤害"
	config.bfDir["<追猎>"] = "夏小尘猎杀该目标，目标闪避降低50%，对其造成的伤害提升15%"
	config.bfDir["<蛊惑>"] = "增加15%伤害，痛击友军"
	config.bfDir["<魔力丸丸>"] = "给“魔法扇”提供特殊效果"
	config.bfDir["<神谕>"] = "场上有此单位以外的友军存在时，免疫死亡，无法吸引仇恨但会被技能伤害溅射到，神谕期间每次受到的伤害由随机队友承担"
	config.bfDir["<铜锣印记>"] = "使用麟珍鬼邪时，若拥有铜锣印记，则消耗印记对敌方全体造成圣舞麒麟魔攻80%的额外伤害（消耗印记的该次技能不叠加印记）"
	config.bfDir["<舞麟>"] = "提升魔攻10%，最高60%(共享上限)"
	config.bfDir["<哼！>"] = "附带<灼烧><破甲>5秒"
	config.bfDir["<我、我才不是帮你呢！>"] = "我方全体获得圣舞麒麟双攻之和的护盾"
	config.bfDir["<希望之神>"] = "免疫异常状态，受到攻击至少剩余1体力，时长可叠加,不可驱散"

func _connect():
	pass
	
#蛊惑
class guhuo:
	extends Buff
	var tempTarget = null
	var dispelable = false
	func _init(lv = 1):
		attInit()
		id = "guhuo"
		life = lv
		isNegetive=true
		att.atkL += 0.15
	func _connect():
		masCha.connect("onKillChara",self,"_onKillChara")
		if !masCha.skills.empty():
			for sk in masCha.skills:
				sk.nowTime -= (life * (1 + masCha.att.cd))
		sech()
	func sech():
		var chas
		chas = masCha.getAllChas(2)
		chas.sort_custom(self,"sort")
		if chas.size() > 1:
			for cha in chas:
				if cha != null && !cha.isDeath && cha != masCha:
					masCha.aiCha = cha
					tempTarget = cha
					break
		else:
			masCha.aiOn = false
			masCha.aiCha = null
	func _upS():
		if tempTarget != null && !tempTarget.isDeath && masCha.aiCha != tempTarget && masCha.aiOn == true:
			masCha.aiCha = tempTarget
		elif masCha.aiOn == true && (tempTarget == null || tempTarget.isDeath):
			sech()
	func _onKillChara(atkInfo):
		tempTarget = null
		sech()
	func _del():
		masCha.aiCha = null
		masCha.aiOn = true

	func sort(a,b):
		if masCha.cellRan(a.cell,masCha.cell) < masCha.cellRan(b.cell,masCha.cell) :
			return true
		return false


#追猎
class zhuilie:
	extends Buff
	var dispelable = false
	func _init(lv = 1):
		attInit()
		id = "zhuilie"
		life = lv*3
		att.dod = -0.5

#诅咒
class zuzhou:
	extends Buff
	func _init(lv = 1):
		attInit()
		id = "zuzhou"
		life = lv
		var dispelable = false
		isNegetive = true
	func _connect():
		masCha.connect("onAtkChara",self,"_onAtkChara")
		masCha.connect("onCastCdSkill",self,"onCastCdSkill")
	func _onAtkChara(atkInfo:AtkInfo):
		if atkInfo.atkType == Chara.AtkType.NORMAL:
			masCha.hurtChara(masCha, masCha.att.atk*0.5, Chara.HurtType.PHY, Chara.AtkType.EFF)
	func onCastCdSkill(id):
		masCha.hurtChara(masCha, masCha.att.mgiAtk, Chara.HurtType.MGI, Chara.AtkType.EFF)


#沼泽
class zhaoze:
	extends Buff
	var dispelable = false
	func _init(lv = 1):
		attInit()
		id = "zhaoze"
		life = lv
		isNegetive=false
		att.spd -= 0.3
	func _upS():
		masCha.hurtChara(masCha,masCha.att.hp * 0.07,Chara.HurtType.MGI,Chara.AtkType.EFF)

#耀光
class yaoguang:
	extends Buff
	var dispelable = false
	func _init():
		attInit()
		id = "yaoguang"

#麻痹
class mabi:
	extends Buff
	func _init(lv=1):
		._init()
		id="mabi"
		var dispelable = false
		isNegetive=true
		life=lv
	func _connect():
		masCha.connect("onCastCdSkill",self,"run")
	func run(id):
		if sys.rndPer(50):
			for i in masCha.skills:
				i.nowTime = 0
			

#禁疗
class b_jinliao:
	extends Buff
	func _init(lv = 1):
		attInit()
		var dispelable = false
		life = lv * 2
		isNegetive = true
	func init():
		pass
	var tmp
	func _connect():
		._connect()
		if masCha.att.reHp != -1:
			tmp = masCha.att.reHp
			masCha.att.reHp = -1
	func _del():
		._del()
		masCha.att.reHp = tmp
	func _upS():
		if masCha.att.reHp != -1:
			masCha.att.reHp = -1


#寄生
class jisheng:
	extends Buff
	var cha = null
	var dispelable = false
	func _init(lv=1,cha = null):
		._init()
		id="jisheng"
		isNegetive=true
		life=lv
		self.cha = cha
	func _upS():
		._upS()
		if cha:
			cha.hurtChara(masCha,masCha.att.maxHp * 0.03,Chara.HurtType.REAL,Chara.AtkType.EFF)
			cha.plusHp(masCha.att.maxHp * 0.03)
		else:
			isDel = true

#束缚
class shufu:
	extends Buff
	func _init(dur=1):
		._init()
		var dispelable = false
		id="shufu"
		isNegetive=true
		life=dur
		
	var oriAi

	func _connect():
		._connect()
		masCha.aiOn = false
	func _upS():
		masCha.aiOn = false
	func _del():
		masCha.aiOn = true
		._del()

#混乱
class hunluan:
	extends Buff
	func _init(lv = 1):
		attInit()
		var dispelable = false
		id = "hunluan"
		life = lv
		isNegetive = false
	func _upS():
		var alls = masCha.rndChas(masCha.getAllChas(0),1)
		masCha.aiCha = alls


#破甲
class pojia:
	extends Buff
	var dispelable = false
	func _init(lv = 1):
		attInit()
		id = "pojia"
		life = lv
		isNegetive=true
		att.defL -= 0.5

class fachuan:
	extends Buff
	var dispelable = false
	func _init(lv = 1):
		attInit()
		id = "fachuan"
		life = lv
		isNegetive=false
		att.mgiDefL += 0.3

#中毒
class zhongdu:
	extends Buff
	var dispelable = false
	func _init(lv = 1):
		attInit()
		id = "zhongdu"
		life = lv
		isNegetive=true
	func _upS():
		masCha.hurtChara(masCha,masCha.att.maxHp * 0.04,Chara.HurtType.PHY,Chara.AtkType.EFF)

#溺水
class nishui:
	extends Buff
	var dispelable = false
	func _init(lv = 1):
		attInit()
		id = "nishui"
		life = lv
		isNegetive=true
	func _upS():
		masCha.hurtChara(masCha,masCha.att.maxHp * 0.05,Chara.HurtType.MGI,Chara.AtkType.EFF)

#灼烧
class zhuoshao:
	extends Buff
	var dispelable = false
	func _init(lv = 1):
		attInit()
		id = "zhuoshao"
		life = lv
		isNegetive=true
	func _upS():
		life = min(20, life)
		masCha.hurtChara(masCha,masCha.att.maxHp * (0.01 + life * 0.002),Chara.HurtType.REAL,Chara.AtkType.EFF)

#免疫负面效果(持续时间版)
class b_gb_myfm:
	extends Buff
	var dispelable = true
	func _init(lv = 1):
		attInit()
		id = "b_gb_myfm"
		life = lv
	func _connect():
		masCha.connect("onAddBuff",self,"onAddBuff")
	func onAddBuff(buff):
		if buff.isNegetive:
			buff.isDel = true


#无敌（按秒数）
class b_wudi:
	extends Buff
	var dispelable = true
	func _init(lv = 1):
		attInit()
		life = lv
		id = "b_wudi"
	func _connect():
		masCha.connect("onHurt",self,"_onHurt")
	func _onHurt(atkInfo:AtkInfo):
		if atkInfo.hurtVal > 0 && not atkInfo.isMiss:
			atkInfo.hurtVal = 0


#朱雀印记
class zhuque:
	extends Buff
	var dispelable = false
	func _init(lv = 1):
		attInit()
		id = "zhuque"
		life = lv

#必定命中
class b_biZhong:
	extends Buff
	func _init(lv = 1):
		attInit()
		id = "b_biZhong"
		life = lv
	func _connect():
		masCha.connect("onAtkChara",self,"run")
	func run(atkInfo):
		if atkInfo.atkType == Chara.AtkType.MISS || atkInfo.isMiss:
			atkInfo.isMiss = false
			atkInfo.atkType = Chara.AtkType.NORMAL

#沉默
class b_cm:
	extends Buff
	var dispelable = false
	func _init(lv = 1):
		attInit()
		id = "b_cm"
		life = lv
		isNegetive=true
	func _upS():
		life = clamp(life,1,10)
		for i in masCha.skills:
			i.nowTime = 0

#坚毅
class baohu:
	extends Buff
	var dispelable = false
	func _init(lv = 1):
		attInit()
		id = "baohu"
		life = lv
		isNegetive=false
	func _upS():
		life = min(20, life)
		att.defL = +(0.05+0.02 * life) * pw

#强攻
class qianggong:
	extends Buff
	var dispelable = false
	func _init(lv = 1):
		attInit()
		id = "qianggong"
		life = lv
		isNegetive=false
	func _upS():
		life = min(20, life)
		att.atkL = +(0.1+0.02 * life) * pw

#无敌（按次数）
class mianyi:
	extends Buff
	var dispelable = true
	var eff2
	var num = 0
	func _init(num = 1):
		attInit()
		id = "mianyi"
		self.num = num
	func _connect():
		masCha.connect("onHurt", self, "onHurt")
	func onHurt(atkInfo:AtkInfo):
		if atkInfo.hurtVal > 0 && not atkInfo.isMiss and num > 0:
			atkInfo.hurtVal = 0
			num -= 1
			if masCha.has_method("afterShengDun"):
				masCha.afterShengDun(atkInfo.atkCha)
		if num <= 0:
			isDel = true

#击晕
class jiyun:
	extends Buff
	var dispelable = false
	func _init(lv = 1):
		attInit()
		id = "jiyun"
		life = lv*0.5
		isNegetive=true
	func _connect():
		masCha.aiOn = false
		if !masCha.skills.empty() :
			for sk in masCha.skills:
				sk.nowTime -= (life * (1 + masCha.att.cd))
	func _upS():
		masCha.aiOn = false
	func _del():
		masCha.aiOn = true

#硬直
class yingzhi:
	extends Buff
	var dispelable = false
	func _init(lv = 1):
		attInit()
		id = "yingzhi"
		life = lv
		isNegetive=true
		att.dod -= 0.5
	func _connect():
		masCha.aiOn = false
		if !masCha.skills.empty() :
			for sk in masCha.skills:
				sk.nowTime -= (life * (1 + masCha.att.cd))
	func _upS():
		masCha.aiOn = false
	func _del():
		masCha.aiOn = true

#摔倒
class shuaidao:
	extends Buff
	var dispelable = false
	func _init(lv = 1):
		attInit()
		id = "shuaidao"
		life = lv*3
		isNegetive=true
		att.defR -= 0.2
	func _connect():
		masCha.aiOn = false
		if !masCha.skills.empty() :
			for sk in masCha.skills:
				sk.nowTime -= (life * (1 + masCha.att.cd))
	func _upS():
		masCha.aiOn = false
	func _del():
		masCha.aiOn = true

class baofu:
	extends Buff
	var dispelable = false
	func _init(lv = 1):
		attInit()
		id = "baofu"
		life = lv*3
		isNegetive=true
		att.spd -= 0.8
		att.atkR -= 0.3

#==========================================================全属性相关==================================================================
#物攻
class wugong1:
	extends Buff
	func _init():
		attInit()
		isNegetive=false
		var dispelable = false
		id = "wugong1"	
		att.atkL = 0.1

class wugong2:
	extends Buff
	func _init():
		attInit()
		isNegetive=false
		var dispelable = false
		id = "wugong2"	
		att.atkL = 0.2

#魔攻
class mogong1:
	extends Buff
	func _init():
		attInit()
		isNegetive=false
		var dispelable = false
		id = "mogong1"	
		att.mgiAtkL = 0.1

class mogong2:
	extends Buff
	func _init():
		attInit()
		isNegetive=false
		var dispelable = true
		id = "mogong1"	
		att.mgiAtkL = 0.2

#防御
class wukang1:
	extends Buff
	func _init():
		attInit()
		isNegetive=false
		var dispelable = false
		id = "wukang1"	
		att.defL = 0.1

class wukang2:
	extends Buff
	func _init():
		attInit()
		isNegetive=false
		var dispelable = false
		id = "wukang2"	
		att.defL = 0.2

#魔抗
class mokang1:
	extends Buff
	func _init():
		attInit()
		isNegetive=false
		var dispelable = false
		id = "mokang1"	
		att.mgiDefL = 0.1

class mokang2:
	extends Buff
	func _init():
		attInit()
		isNegetive=false
		var dispelable = false
		id = "mokang2"	
		att.mgiDefL = 0.2

#攻速
class gongsu1:
	extends Buff
	func _init():
		attInit()
		isNegetive=false
		var dispelable = false
		id = "gongsu1"	
		att.spd = 0.1

class gongsu2:
	extends Buff
	func _init():
		attInit()
		isNegetive=false
		var dispelable = false
		id = "gongsu2"	
		att.spd = 0.2

#闪避
class shanbi1:
	extends Buff
	func _init():
		attInit()
		isNegetive=false
		var dispelable = false
		id = "shanbi1"	
		att.dod = 0.1

class shanbi2:
	extends Buff
	func _init():
		attInit()
		isNegetive=false
		var dispelable = false
		id = "gongsu2"	
		att.dod = 0.2

#暴击
class baoji1:
	extends Buff
	func _init():
		attInit()
		isNegetive=false
		var dispelable = false
		id = "baoji1"	
		att.cri = 0.1

class baoji2:
	extends Buff
	func _init():
		attInit()
		isNegetive=false
		var dispelable = false
		id = "baoji2"	
		att.cri = 0.2
#爆伤
class baoshang1:
	extends Buff
	func _init():
		attInit()
		isNegetive=false
		var dispelable = false
		id = "baoshang1"	
		att.criR = 0.1

class baoshang2:
	extends Buff
	func _init():
		attInit()
		isNegetive=false
		var dispelable = false
		id = "baoshang2"	
		att.criR = 0.2

#冷却
class lengque1:
	extends Buff
	func _init():
		attInit()
		isNegetive=false
		var dispelable = false
		id = "lengque"	
		att.cd += 0.1

#减伤
class jianshang1:
	extends Buff
	func _init():
		attInit()
		isNegetive=false
		var dispelable = false
		id = "jianshang1"	
		att.defR += 0.05
#===========================================削弱全属性相关================================================================

#攻速
class jgongsu:
	extends Buff
	func _init(lv = 1):
		attInit()
		var dispelable = false
		isNegetive=true
		life = lv
		id = "jgongsu"	
		att.spd -= 0.2